const mongoose = require('mongoose');
function connect(url) {
    mongoose.Promise = global.Promise; // 消除 mongoose 的promise 替换警告，至于为什么有这个警告不清楚
    mongoose.connect(url);
  
    const db = mongoose.connection;
    db.on('error', console.error.bind(console, 'connection error:'));
    db.once('open', () => {
      // yay!
      console.log('mongodb connect success on "'+url+'" by mongoose');
    });
  }
  
  module.exports = connect;